<%@ page language="java" pageEncoding="UTF-8"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<jsp:directive.page import="java.util.List" />

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
<head>
	<html:base />

	<title>article_query.jsp</title>
	<link rel="stylesheet" type="text/css" href="skin/css/base.css">
</head>
<script language="JavaScript">
function passArc(aid){
	var qstr=getCheckboxItem();
	if(aid==0) aid = getOneItem();
	location="CommentManagement.do?method=passComments&id="+qstr+"";
}
function noPassArc(aid){
	var qstr=getCheckboxItem();
	if(aid==0) aid = getOneItem();
	location="CommentManagement.do?method=noPassComments&id="+qstr+"";
}
function delArc(aid){
if(confirm("确定要删除此评论信息吗？")){
	var qstr=getCheckboxItem();
	if(aid==0) aid = getOneItem();
	location="CommentManagement.do?method=deleteComments&id="+qstr+"";
	}
}
//获得选中文件的文件名
function getCheckboxItem()
{
	var allSel="";
	if(document.articleform.id.value) return document.articleform.id.value;
	for(i=0;i<document.articleform.id.length;i++)
	{
		if(document.articleform.id[i].checked)
		{
			if(allSel=="")
				allSel=document.articleform.id[i].value;
			else
				allSel=allSel+"|"+document.articleform.id[i].value;
		}
	}
	return allSel;
}

//获得选中其中一个的id
function getOneItem()
{
	var allSel="";
	if(document.articleform.id.value) return document.articleform.id.value;
	for(i=0;i<document.articleform.id.length;i++)
	{
		if(document.articleform.id[i].checked)
		{
				allSel = document.articleform.id[i].value;
				break;
		}
	}
	return allSel;
}
function selAll()
{
	for(i=0;i<document.articleform.id.length;i++)
	{
		if(!document.articleform.id[i].checked)
		{
			document.articleform.id[i].checked=true;
		}
	}
}
function noSelAll()
{
	for(i=0;i<document.articleform.id.length;i++)
	{
		if(document.articleform.id[i].checked)
		{
			document.articleform.id[i].checked=false;
		}
	}
}
</script>
<jsp:useBean id="pagination" class="icms.service.MyPagination"
	scope="session"></jsp:useBean>
<%
	String condition = "method=queryArticles";
		//分页操作
		String str = request.getParameter("Page");
		int Page = 1;
		List list = null;
		if (str == null) {
			list = (List) request.getAttribute("list");
			int pagesize = 10; //指定每页显示的记录数

			list = pagination.getInitPage(list, Page, pagesize); //初始化分页信息
		} else {
			Page = pagination.getPage(str);
			list = pagination.getAppointPage(Page); //获取指定页的数据
		}
%>
<body leftmargin="8" topmargin="8" background='skin/images/frame/allbg.gif'>

	<!--  快速转换位置按钮  -->
	<table width="98%" border="0" cellpadding="0" cellspacing="1"
		bgcolor="#D1DDAA" align="center">
		<tr>
			<td height="26" background="skin/images/newlinebg3.gif">
				<table width="98%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td align="center">
							<input type='button' class='coolbg np' onClick="location='';"
								value='文章列表' />
							<input type='button' class="coolbg np" onClick="location='';"
								value='评论列表' />
							<input type='button' class="coolbg np" onClick="location='';"
								value='更新列表' />
							<input type='button' class="coolbg np" onClick="location='';"
								value='更新文档' />
							<input type='button' class="coolbg np" onClick="location='';"
								value='文章回收站' />
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	<!--  搜索表单  -->
	<form name='searchform' action='' method='get'>
		<input type='hidden' name='dopost' value='' />
		<table width='98%' border='0' cellpadding='1' cellspacing='1'
			bgcolor='#CBD8AC' align="center" style="margin-top: 8px">
			<tr bgcolor='#EEF4EA'>
				<td background='skin/images/wbg.gif' align='center'>
					<table border='0' cellpadding='0' cellspacing='0'>
						<tr>
							<td width='90' align='center'>
								搜索条件：
							</td>
							<td width='160'>
								<select name='cid' style='width: 150'>
									<option value='0'>
										选择类型...
									</option>
									<option value='1'>
										名称
									</option>
								</select>
							</td>
							<td width='70'>
								关键字：
							</td>
							<td width='160'>
								<input type='text' name='keyword' value='' style='width: 150px' />
							</td>
							<td width='110'>
								<select name='orderby' style='width: 80px'>
									<option value='id'>
										排序...
									</option>
									<option value='pubdate'>
										发布时间
									</option>
								</select>
							</td>
							<td>
								<input name="imageField" type="image"
									src="skin/images/frame/menusearch.gif" width="16px"
									height="16px" border="0" class="np" />
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</form>
	<!--  内容列表   -->
	<form name="articleform">
		<table width="98%" border="0" cellpadding="1" cellspacing="1"
			bgcolor="#D1DDAA" align="center" style="margin-top: 8px">
			<tr bgcolor="#E7E7E7">
				<td height="24" colspan="8" background="skin/images/tbg.gif">
					&nbsp;文章列表&nbsp;
				</td>
			</tr>
			<tr align="center" bgcolor="#FAFAF1" height="22">
				<td width="4%">
					选择
				</td>
				<td width="20px">
					ID
				</td>
				<td width="30px">
					标题
				</td>
				<td width="200px">
					内容
				</td>
				<td width="40px">
					作者
				</td>
				<td width="60px">
					发表时间
				</td>
				<td width="55px">
					是否通过
				</td>
				<td width="60px">
					操作
				</td>
			</tr>
			<logic:iterate id="ArticleList" collection="<%=list%>">
				<bean:define id="articleId" name="ArticleList" property="articleId" />
				<bean:define id="articleApproved" name="ArticleList"
					property="articleApproved" />
				<%
					if (articleApproved.equals(1)) {
									articleApproved = "通过";
								}
								if (articleApproved.equals(0)) {
									articleApproved = "撤回";
								}
				%>
				<tr align='center' bgcolor="#FFFFFF"
					onMouseMove="javascript:this.bgColor='#E7E7E7';"
					onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
					<td>
						<input name="id" type="checkbox" id="id" value="<%=articleId%>"
							class="np">
					</td>
					<td>
						<bean:write name="ArticleList" property="articleId" format="#" />
					</td>
					<td>
						<bean:write name="ArticleList" property="articleTitle" />
					</td>
					<td>
						<bean:write name="ArticleList" property="articleBody" />
					</td>
					<td>
						<bean:write name="ArticleList" property="artilceEditor" />
					</td>
					<td>
						<bean:write name="ArticleList" property="articleEditTime"
							format="yyyy-mm-dd" />
					</td>
					<td>
						<%=articleApproved%>
					</td>
					<td>
						<a href="ArticleManagement.do?method=editOneArticle&id=<%=articleId%>">编辑</a>
						<a href="javascript:deleteOneComment('<%=articleId%>')">删除</a>
					</td>
				</tr>
			</logic:iterate>
			<tr bgcolor="#FAFAF1">
				<td height="28" colspan="8">
					&nbsp;
					<a href="javascript:selAll()" class="coolbg">全选</a>
					<a href="javascript:noSelAll()" class="coolbg">取消</a>
					<a href="javascript:passArc(0)" class="coolbg">&nbsp;通过&nbsp;</a>
					<a href="javascript:noPassArc(0)" class="coolbg">&nbsp;撤回&nbsp;</a>
					<a href="javascript:delArc(0)" class="coolbg">&nbsp;删除&nbsp;</a>
				</td>
			</tr>
			<tr>
				<td>
					<div align="right"><%=pagination.printCtrl(Page, condition)%></div>
				</td>
			</tr>
		</table>
	</form>
</body>
</html:html>
